<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>迭代器</title>
</head>
<body>
    <script>
        // 声明一个数组
        let xiyou = [`唐僧`, `孙悟空`, `猪八戒`, `沙僧`];
        // 使用 for...of 遍历数组
        for(let v of xiyou){
            console.log(v);
        }

        let iterator = xiyou[Symbol.iterator]();

        // 调用对象的 next 方法
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());
        console.log(iterator.next());
    </script>
</body>
</html>